import axios from "@u/request";

// 获取轮播  /banner/list
const bannerList = (params = {}) => axios.get("/banner/list", { params });

//商品分类  /shop/goods/category/all
const featchCate = (params = {}) =>
  axios.get("/shop/goods/category/all", { params });

// 商品列表 /shop/goods/list/v2
const ProductLists = (params = {}) => axios.post("/shop/goods/list/v2", params);

// 商品详情 /shop/goods/detail
const cateContentLists = (params = {}) =>
  axios.get("/shop/goods/detail", { params });

// 加入购物车 /shopping-cart/add
const addCart = (params = {}) => axios.post("/shopping-cart/add", params);

// 清空购物车 /shopping-cart/empty
const clearCart = (params = {}) => axios.post("/shopping-cart/empty", params);

// 读取购物车数据 /shopping-cart/info
const readCart = (params = {}) => axios.get("/shopping-cart/info", { params });

// 购物车修改购买数量 /shopping-cart/modifyNumber
// const updateCart = (params = {}) =>
//   axios.post("/shopping-cart/modifyNumber", params);

// 移除购物车中某条记录 /shopping-cart/remove
const removeCart = (params = {}) => axios.post("/shopping-cart/remove", params);

// 购物车修改选中状态 /shopping-cart/select
const checkCart = (params = {}) => axios.post("/shopping-cart/select", params);

// 登录接口
const getLoginApi = (data) => axios.post("/user/login", data);

// 注册接口
const getRegApi = (data) => axios.post("/user/register", data);

// 重置密码接口
const getSetPasswordApi = (data) => axios.post("/user/password/rest", data);

// 获取商品列表
const getProductList = () => axios.get("/product/findAll");

// 加入购物车
const addShoppingCartApi = (data) => axios.post("/cart/addToCart", data);

// 修改购物车商品
const updateCart = (data) => axios.put("/cart/updateCart", data);

// 改变选中状态
const isCheckedApi = (data) => axios.put("/cart/updateCartStatus", data);

// 评论接口
const getCommentApi = (data) => axios.post("/comment/commentProduct", data);

// 上传用户头像
const getUserAvatar = (data) => axios.post("/product/upload", data);

// 修改用户信息
const putUserInfo = (data) => axios.put("/user", data);

// 下单功能
const addOrder = (data) => axios.post("/order/addOrder", data);
export {
  addOrder,
  putUserInfo,
  getUserAvatar,
  getCommentApi,
  isCheckedApi,
  addShoppingCartApi,
  getProductList,
  getSetPasswordApi,
  getRegApi,
  getLoginApi,
  bannerList,
  featchCate,
  ProductLists,
  cateContentLists,
  addCart,
  clearCart,
  readCart,
  updateCart,
  removeCart,
  checkCart,
};
